package net.uhuijia.software.softwareQcode.controller;

import net.uhuijia.appbase.controller.BaseController;
import net.uhuijia.enums.MoreInfo;
import net.uhuijia.software.softwareQcode.persistence.model.SoftwareQcode;
import net.uhuijia.software.softwareQcode.persistence.model.SoftwareQcodeExample;
import net.uhuijia.software.softwareQcode.service.SoftwareQcodeService;
import net.uhuijia.user.usermall.clientservice.UserMallClientService;
import net.uhuijia.user.usermall.persistence.model.UserMall;
import net.uhuijia.utils.IticConst;
import net.uhuijia.utils.ValueHelper;
import net.uhuijia.vo.ResultMapVo;
import net.uhuijia.vo.ReturnListVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.util.List;
import java.util.Map;


@RestController
@RequestMapping(value="/softwareqcode")
public class SoftwareQcodeController
     extends BaseController<SoftwareQcodeService,SoftwareQcode,SoftwareQcodeExample> {

    @Autowired
    private UserMallClientService userMallClientService;

    @RequestMapping(value = "/history")
    @ResponseBody
    public ResultMapVo<ReturnListVo<Map<String, Object>>> history(HttpServletRequest request ){
        UserMall user = this.getUserMallByTokenAndDevice();
        List<SoftwareQcode> list = s.historylist(request,user);
        List<Map<String, Object>> tranList2MapList = ValueHelper.tranList2MapList(list, ignoreProperties);
        Integer count = s.countUserHistoryRequest(user);
        MoreInfo moreInfo = IticConst.isMore(request,count);
        ReturnListVo<Map<String, Object>> resultList = new ReturnListVo<>(tranList2MapList,count, moreInfo);
        return ResultMapVo.ok(resultList);
    }
}